package com.ciaojian.client.listener;

import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.support.Acknowledgment;
import org.springframework.kafka.support.KafkaHeaders;
import org.springframework.messaging.handler.annotation.Header;

/**
 * 订单消息监听器
 * @author oxiny
 */
//@Component
public class OrderListener {

    @KafkaListener(topics = {"user.register.topic"},groupId = "wyl-gp2")
    public void onMessage(ConsumerRecord<?, ?> record, Acknowledgment ack,
                          @Header(KafkaHeaders.RECEIVED_TOPIC) String topic) {
        System.out.println("消费消息："+record.topic()+"----"+record.partition()+"----"+record.value());
        ack.acknowledge();
    }
}
